package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;

public class ProgressBarActivity extends AppCompatActivity {
    private int progress;
    private  ProgressBar bar;
    private  ProgressBar bar2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_progress_bar);
         bar = findViewById(R.id.progress_bar_view);
         bar2 = findViewById(R.id.progress_bar_view2);
        Button bun = findViewById(R.id.change_bar_view);
        Button bun2 = findViewById(R.id.change_bar_view2);

        bun.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(bar.getVisibility() == View.GONE){
                    bar.setVisibility(View.VISIBLE);
                }else{
                    bar.setVisibility(View.GONE);
                }
            }
        });
    }

    public void load(View view) {
        int progress = bar2.getProgress();
        progress += 10;
        if(progress>100){
            progress = 0;
        }
        bar2.setProgress(progress);
    }
}